package com.njust.RateMyTray_backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njust.RateMyTray_backend.entity.Report;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ReportMapper extends BaseMapper<Report> {
    @Select("<script>" +
            "SELECT id, reporter_id, target_id AS reportedContentId, target_type AS reportedContentType, " +
            "reason, status, processor_id, reported_at AS createdAt, processed_at AS updatedAt " +
            "FROM t_report" +
            "<where>" +
            "<if test='status != null'>" +
            "AND status = #{status}" +
            "</if>" +
            "<if test='reportedContentType != null'>" +
            "AND target_type = #{reportedContentType}" +
            "</if>" +
            "</where>" +
            "</script>")
    List<Report> selectReports(@Param("status") String status, @Param("reportedContentType") String reportedContentType);
} 